package service;

import dao.MedicalAdviceDAO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import pojo.MedicalAdvice;

import java.util.List;
@Service
public class MedicalAdviceServiceImpl implements MedicalAdviceService {
    @Autowired
    private MedicalAdviceDAO dao;
    @Override
    public List<MedicalAdvice> queryByMedical(MedicalAdvice medicalAdvice) {
        return dao.queryByMedical(medicalAdvice);
    }

    @Transactional
    public void update(MedicalAdvice medicalAdvice,Integer status) {
        MedicalAdvice medicalAdvice1 = dao.queryById(medicalAdvice.getId());
        medicalAdvice.getRegistry().setStatus(status);
    }

    @Transactional
    public void addMed(MedicalAdvice medicalAdvice) {
        dao.save(medicalAdvice);
    }

    @Override
    public List<MedicalAdvice> queryByYz(MedicalAdvice medicalAdvice) {
        return dao.queryByYz(medicalAdvice);
    }

    @Transactional
    public void updateMed(MedicalAdvice medicalAdvice) {
        MedicalAdvice m = dao.queryById(medicalAdvice.getId());
        m.setChiefComplaint(medicalAdvice.getChiefComplaint());
        m.setDiagnosis(medicalAdvice.getDiagnosis());
    }
}
